<template>
	<view>
		<view style="height: 1rpx;width: 1rpx;"></view>
		<view class="address-each" v-for="(item,index) in shopList" @click="select(item)">
			<view class="image"><image :src="currnetShop.id == item.id ? '../../static/login/choosed.png' : '../../static/login/choose.png'" mode=""></image></view>
			<view class="shop">
				<view class="shop-img"> <image :src="$oss(item.images)" mode="aspectFill"></image> </view>
				
				<view class="shop-r">
					<view class="shop-name">{{item.name}}</view>
					<view class="shop-site">
						<view class="site">{{item.address}}</view>
						<view class="juli">{{item.distance}}km</view>
					</view>
					<view class="money">
						<view class="">
							<text>{{item.start_price}}</text>起
						</view>
						<image src="../../static/my/shop-site.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		
		<view style="height: 120rpx;width: 1rpx;"></view>
		<view class="btn-box">
			<view class="PlaceAnOrder-btn" @click="confirmShop">确定</view>
		</view>
	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				shopList:[],
				current:1,
				currnetShop:{},
				page:1,
			}
		},
		onLoad(option) {
			this.current = option.id
			this.getCity()
		},
		methods: {
			...mapActions(['getLocation']),
			async getCity() {
				if (!this.$store.state.location) {
					await this.getLocation()
				}
				this.location = JSON.parse(JSON.stringify(this.$store.state.location))
				this.getShopList()
			},
			getShopList(){
				this.$api.post('/getStoreList',{
					page:this.page,
					city:this.location.city,
					lat:this.location.lat,
					lng:this.location.lng
				}).then((res) => {
					if(res.data){
						this.shopList = res.data
						
					}
				}).catch((res) => {});
			},
			select(item){
				this.currnetShop = item
				this.current = item.id
			},
			confirmShop(){
				if(!this.currnetShop.id) return this.$toast('请选择门店')
				const eventChannel = this.getOpenerEventChannel();
				eventChannel.emit('selectShop',this.currnetShop);
				this.$back();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F7F8FA;
	}
	.address-each {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 32rpx;
		margin-top: 24rpx;
		.image {
			width: 32rpx;
			height: 32rpx;
			padding-right: 24rpx;
			image {
				width: 32rpx;
				height: 32rpx;
			}
		}
		
		.shop {
			background-color: #FFF;
			padding: 24rpx;
			display: flex;
			align-items: center;
			border-radius: 20rpx;
			min-width: 560rpx;
			.shop-img {
				width: 148rpx;
				height: 148rpx;
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				image {
					width: 148rpx;
					height: 148rpx;
					border-radius: 24rpx 24rpx 24rpx 24rpx;
				}
			}
			.shop-r {
				margin-left: 24rpx;
				.shop-name {
					font-weight: bold;
					font-size: 28rpx;
					color: #1C274C;
				}
				.shop-site {
					font-weight: 500;
					font-size: 22rpx;
					color: #6B738B;
					margin-top: 8rpx;
					display: flex;
					justify-content: space-between;
					.site {
						width: 260rpx;
					}
				}
				.money {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-top: 16rpx;
					view {
						font-weight: 500;
						font-size: 24rpx;
						color: #A4A9B7;
						text {
							font-weight: bold;
							font-size: 36rpx;
							color: #FF7B18;
						}
					}
					image {
						width: 40rpx;
						height: 40rpx;
						background: #F7F8FA;
						border-radius: 0rpx 0rpx 0rpx 0rpx;
					}
				}
			}
		}
	}
	
	.btn-box {
		width: 100%;
		position: fixed;
		bottom: 40rpx;
		z-index: 9;
		.PlaceAnOrder-btn {
			width: 686rpx;
			height: 106rpx;
			margin: auto;
			background: #4BC264;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			font-weight: 800;
			font-size: 34rpx;
			color: #FFFFFF;
			line-height: 106rpx;
			text-align: center;
		}
	}
</style>
